home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 5 / QRZ Ham Radio Callsign Database - Volume 5.iso / files / amiga / csrc720j.lzh / makepass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-11  |  807 b   |  33 lines

  1. /* A rather trivial program to generate a random password for CBBS
  2.    using the integers from 1 to 99
  3.    Pete VE5VA
  4. */
  5. int vector[100];
  6. long dates[3];
  7. main(argc,argv)
  8. int argc;
  9. char *argv[];
  10. {
  11.  
  12.    register int j,k,l;
  13.  
  14.    DateStamp((struct DateStamp *)&dates[0]);
  15.    srand((short)((dates[0]*50 + dates[2]) | 1));
  16.    /* j counts the 64 numbers. 'l' is used to limit the number of times
  17.       around the loop because rand() is not a super efficient generator
  18.       of random numbers and can itself go into a loop.
  19.    */
  20.    for(j=0,l=0;(j < 64) && (l<2000);l++) {
  21.       k = rand()%99 + 1;
  22.       if(vector[k])continue;
  23.       vector[k] = 1;
  24.       printf("%3d",k);
  25.       j++;
  26.       if((j % 10) == 0)printf("\n");
  27.    }
  28.    printf("\n");
  29.    if(l >= 2000) {
  30.       printf("rand must have looped - try again\n");
  31.    }
  32. }
  33.